/**
 * BRISA Sociedade para o Desenvolvimento da Tecnologia da Informa��o 
 * @link www.brisa.org.br
 * @since 24/10/2007
 * @author jleite
 */
package br.com.agoravai16072011.common;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * @author Jo�o Paulo Leite (jleite) <joao.leite@brisa.org.br>
 * 
 */
public class UtilProperties {

	private static Properties properties = null;
	private static UtilProperties utilProperties = null;
	
	/**
	 * @author jleite
	 * @date 24/10/2007 15:59:36
	 */
	private UtilProperties(String initPropertiesPath) {
		properties = new Properties();
		InputStream inputStream;
		try {
			inputStream = new FileInputStream(new File(initPropertiesPath));
			properties.load(inputStream);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * 
	 * @author jleite
	 * @since 24/10/2007 16:19:30
	 * @return UtilProperties
	 * @param path
	 * @return
	 */
	public static UtilProperties getInstance(String initPropertiesPath){
		if(utilProperties == null)utilProperties = new UtilProperties(initPropertiesPath);
		return utilProperties;
	}
	
	/**
	 * 
	 * @author jleite
	 * @since 24/10/2007 16:19:27
	 * @return Properties
	 * @return
	 */
	public static Properties getInitProperties(){
		return properties;
	}
	
	/**
	 * 
	 * @author jleite
	 * @since 28/11/2007 13:31:45
	 * @return String
	 * @param key
	 * @return
	 */
	public static String getProperty(String key){
		return properties.getProperty(key);
	}
}
